<%@ include file="partials/header.jsp" %>
<%@ page import="bounjour.User" %>
<%@ page import="java.util.ArrayList" %>
			<div class="main">
			<!-- 
				<div class="side"></div>
			 -->	
				<div class="center">				
<%

// there is post data, get get all data
if ("POST".equals(request.getMethod())) {
	
	String displayName = request.getParameter("displayName").trim();
	String userEmail = request.getParameter("userEmail").trim();
	String userPassword = request.getParameter("userPassword").trim();
	String userPassword2 = request.getParameter("userPassword2").trim();
	
	ArrayList <String> errorList = new ArrayList<String>();
	
	errorList = User.register(displayName, userEmail, userPassword, userPassword2); 
	
	if (errorList.size() > 0) {
		
		 for (String err : errorList){
			 out.println("<p class=\"failureNotification\">"+ err +"</p>");
		 }
		
	}else {
		out.println("<p class=\"successNotification\">Bounjour "+displayName +"! You are now registered. Want to post your first message? <a href=\"post.jsp\" title=\"Post\">Click here</a></p>");
	}
	
	
	

}
%>				
			<form name="register" method="post" enctype="application/x-www-form-urlencoded" action="register.jsp">
			<fieldset style="background:#EFEFEF;">	
			<p style="font-weight: bold;">Register</p>
			<p><label style="float:left;width:150px;">Display Name</label><input name="displayName" type="text"  /></p>
			<p><label style="float:left;width:150px;">User Email</label><input name="userEmail" type="text"  /></p>
			<p><label style="float:left;width:150px;">Password</label><input name="userPassword" type="password"  /></p>
			<p><label style="float:left;width:150px;">Confirm Password</label><input name="userPassword2" type="password"  /></p>
			
			<input type="submit" name="submit" value="Register" />
			</fieldset>	
			</form>			
			</div>
			</div>
<%@ include file="partials/footer.jsp" %>				
			
